package com.jianganming.chain;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

class DateSource {

    private Map<String,User> user = new ConcurrentHashMap<>();

    private Map<String,List<Role>> role = new ConcurrentHashMap<>();

    public Map<String,User> getUser(){
        return user;
    }

    public Map<String,List<Role>> getRole(){
        return role;
    }

    private DateSource(){
        user.put("jianganming",new User("jianganming","1234556"));
        user.put("admin",new User("admin","admin123"));
        user.put("admin01",new User("admin01","1234556"));
        user.put("admin02",new User("admin02","1234556"));
        user.put("admin03",new User("admin03","1234556"));
        Role role1 = new Role(1, "财务");
        Role role2 = new Role(2, "管理员");
        Role role3 = new Role(3, "组长");
        Role role4 = new Role(4, "会计");
        role.put("jianganming",Arrays.asList(role1,role2,role3));
        role.put("admin",Arrays.asList(role1,role2,role4));
        role.put("admin01",Arrays.asList(role2,role3,role4));
        role.put("admin02",Arrays.asList(role1,role2));
        role.put("admin03",Arrays.asList(role1));
    }

    public static DateSource getDateSourceInstance(){
        return CreateDateSource.getDateSource();
    }

    static class CreateDateSource{
        private static DateSource dateSource= new DateSource();

        public static DateSource getDateSource(){
            return dateSource;
        }
    }
}
